home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume21 / exebyte_toc next >
Encoding:
Internet Message Format  |  1990-04-29  |  20.7 KB

  1. Subject:  v21i102:  Table of Contents for Exebyte 8mm tapes
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: d4b8e147 e5c95135 51ad50a8 cae6dd07
  5.  
  6. Submitted-by: Matt Landau <mlandau@diamond.bbn.com>
  7. Posting-number: Volume 21, Issue 102
  8. Archive-name: exebyte_toc
  9.  
  10. Exetoc is a program that allows you to write a table of contents file onto
  11. the front of a 2GB helical scan tape, read it back later, and update it
  12. without disturbing the other contents of the tape.
  13.  
  14. It does this by reserving a fixed amount of space at the start of the tape
  15. (about 10 megabytes in the current implementation) that can be used to
  16. store information about the contents of the tape.  About 2 megabytes of
  17. this space is available for keeping the table of contents.  The rest acts
  18. as a buffer space between the end of the table of contents and the first
  19. data file on the tape.
  20.  
  21. #! /bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of shell archive."
  28. # Contents:  Makefile exetoc.c smtops.c exitcodes.h smtio.h smtops.h
  29. #   exetoc.man
  30. # Wrapped by mlandau@dilithium on Wed Apr 11 14:41:09 1990
  31. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  32. if test -f Makefile -a "${1}" != "-c" ; then 
  33.   echo shar: Will not over-write existing file \"Makefile\"
  34. else
  35. echo shar: Extracting \"Makefile\" \(765 characters\)
  36. sed "s/^X//" >Makefile <<'END_OF_Makefile'
  37. XSRCS = exetoc.c smtops.c
  38. XOBJS = exetoc.o smtops.o
  39. XHDRS = exitcodes.h smtio.h smtops.h
  40. XDOCS = exetoc.man
  41. X
  42. X# Uncomment this if you have librmt.a installed someplace
  43. XRMT  = -DREMOTE=1 -I/usr/local/include
  44. XLIBS = /usr/local/lib/librmt.a
  45. X
  46. X# Uncomment this if you DON'T have librmt.a installed someplace
  47. X#RMT  =
  48. X#LIBS =
  49. X
  50. XCFLAGS = $(RMT) -O
  51. X
  52. XBINDIR = /usr/local/bin
  53. XMANDIR = /usr/local/man/man1
  54. XMANEXT = 1
  55. X
  56. Xexetoc: $(OBJS)
  57. X    cc $(CFLAGS) -o exetoc $(OBJS) $(LIBS)
  58. X
  59. Xinstall: exetoc
  60. X    install -s exetoc $(BINDIR)
  61. X    cp exetoc.man $(MANDIR)/exetoc.$(MANEXT)
  62. X
  63. Xclean:
  64. X    /bin/rm -f exetoc a.out $(OBJS) core *.BAK *.CKP
  65. X
  66. Xshar:
  67. X    shar Makefile $(SRCS) $(HDRS) $(DOCS) >exetoc.shar
  68. X
  69. Xsaber:
  70. X    # load $(SRCS)
  71. X
  72. X
  73. Xexetoc.o: exitcodes.h smtio.h smtops.h
  74. Xsmtops.o: exitcodes.h smtio.h smtops.h
  75. END_OF_Makefile
  76. if test 765 -ne `wc -c <Makefile`; then
  77.     echo shar: \"Makefile\" unpacked with wrong size!
  78. fi
  79. # end of overwriting check
  80. fi
  81. if test -f exetoc.c -a "${1}" != "-c" ; then 
  82.   echo shar: Will not over-write existing file \"exetoc.c\"
  83. else
  84. echo shar: Extracting \"exetoc.c\" \(8029 characters\)
  85. sed "s/^X//" >exetoc.c <<'END_OF_exetoc.c'
  86. X/* 
  87. X * exetoc.c  --  A program to read, write, and rewrite tables of contents
  88. X *          on tapes in an exebyte tape drive.
  89. X * 
  90. X * USAGE:    exetoc [-t|f tape] [-g file] [-p file] [-i] [-v] [-q]
  91. X * 
  92. X *             -t specifies the tape drive, default is /dev/rsmt0
  93. X *            -f is a synonym for -t, a la mt.
  94. X *             -g gets the table of contents from the tape and
  95. X *                 sticks it into "file", which may be "-"
  96. X *                 for standard output.
  97. X *             -p puts the table of contents contained in "file"
  98. X *                 onto the front of the tape.  You can use
  99. X *                 "-" to take the table of contents from
  100. X *                 standard input.
  101. X *             -i initializes the tape by creating a blank table
  102. X *                 of contents.
  103. X *             -v verifies that this tape has been initialized.
  104. X *             -q causes the program to work quietly.
  105. X * 
  106. X *         You MUST provide exactly one of the -i, -g, -p, or -v flags.
  107. X */
  108. X#if !lint && !SABER
  109. Xstatic char RcsId[] = "$Header: exetoc.c,v 1.3 89/10/27 16:14:34 mlandau Exp $";
  110. X#endif
  111. X
  112. X#include <stdio.h>
  113. X#include <fcntl.h>
  114. X#include <sys/types.h>
  115. X#include <sys/stat.h>
  116. X
  117. X#include "exitcodes.h"
  118. X#include "smtops.h"
  119. X
  120. X#define    FORWARD        /* nothing */
  121. X
  122. X#define KBytes(n)    (n * 1024)
  123. X#define MBytes(n)    (1024 * KBytes(n))
  124. X#define MIN(a, b)    ((a) < (b) ? (a) : (b))
  125. X#define    streq(s1, s2)    (!strcmp(s1, s2))
  126. X
  127. X#define    IOBUF_SIZE    KBytes(62)    /* Exebyte likes 62KB chunks */
  128. X#define TOC_SIZE     MBytes(10)    /* TOC occupied 10 MB on the tape */
  129. X#define    TOC_USEABLE    MBytes(2)    /* About 2 MB of it can be used */
  130. X
  131. X#define TOC_MARKER    "[ExeTOC Table of Contents]"
  132. X
  133. X#define OP_NONE        0
  134. X#define OP_VERIFY    1
  135. X#define OP_INIT        2
  136. X#define OP_FETCH    3
  137. X#define OP_STORE    4
  138. X
  139. X/* Getopt stuff */
  140. Xextern    char    *optarg;
  141. Xextern    int    optind;
  142. Xextern    int    opterr;
  143. X
  144. X/* Linked in later */
  145. Xextern    char    *getenv();
  146. Xextern    char    *rindex();
  147. X
  148. X/* Shut Saber up */
  149. XFORWARD void    usage();
  150. XFORWARD void    set_operation();
  151. XFORWARD void    mark_tape();
  152. XFORWARD    void    initialize_tape();
  153. XFORWARD int    check_tape();
  154. XFORWARD void    toc_to_file();
  155. XFORWARD void    toc_from_file();
  156. XFORWARD void    rewind_named_device();
  157. X
  158. X
  159. X/* Only need one big buffer to hold the table of contents */
  160. Xstatic char Buffer[IOBUF_SIZE];
  161. Xstatic int  Quiet = 0;
  162. X
  163. Xmain(argc, argv)
  164. Xint    argc;
  165. Xchar    **argv;
  166. X{   
  167. X    int      option;
  168. X    int      operation = OP_NONE;
  169. X    char *tapename = "/dev/rsmt0";
  170. X    int      hastoc;
  171. X    int   tapefd;
  172. X    int      tocfd;
  173. X    
  174. X    opterr = 0;
  175. X    if ((tapename = getenv("EXEBYTE")) == NULL)
  176. X    tapename = "/dev/rsmt0";
  177. X    while ((option = getopt(argc, argv, "t:f:g:p:ivq")) != EOF)
  178. X    {   
  179. X    switch (option)
  180. X    {   
  181. X      case 't':
  182. X      case 'f':
  183. X        tapename = optarg;
  184. X        break;
  185. X        
  186. X      case 'g':
  187. X        set_operation(&operation, OP_FETCH);
  188. X        if (streq(optarg, "-"))
  189. X        tocfd = fileno(stdout);
  190. X        else
  191. X        tocfd = check_open(optarg, O_WRONLY|O_CREAT|O_TRUNC, 0666);
  192. X        break;
  193. X        
  194. X      case 'p':
  195. X        set_operation(&operation, OP_STORE);
  196. X        if (streq(optarg, "-"))
  197. X        tocfd = fileno(stdin);
  198. X        else 
  199. X        tocfd = check_open(optarg, O_RDONLY, 0666);
  200. X        break;
  201. X        
  202. X      case 'i':
  203. X        set_operation(&operation, OP_INIT);
  204. X        break;
  205. X        
  206. X      case 'v':
  207. X        set_operation(&operation, OP_VERIFY);
  208. X        break;
  209. X        
  210. X      case 'q':
  211. X        Quiet = 1;
  212. X        break;
  213. X        
  214. X      default:
  215. X        usage(argv[0]);
  216. X        exit(EXIT_USAGE);
  217. X        /* NOTREACHED */
  218. X        break;
  219. X    }
  220. X    }
  221. X    
  222. X    switch (operation)
  223. X    {   
  224. X      case OP_NONE:
  225. X    fputs("You must specify one of -g, -p, -i, or -v\n", stderr);
  226. X    exit(EXIT_USAGE);
  227. X    
  228. X      case OP_INIT:
  229. X    tapefd = smt_open(tapename, O_WRONLY);
  230. X    initialize_tape(tapefd);
  231. X    smt_close(tapefd);
  232. X    rewind_named_device(tapename);
  233. X    exit(EXIT_OK);
  234. X    
  235. X      case OP_VERIFY:
  236. X    tapefd = smt_open(tapename, O_RDONLY);
  237. X    hastoc = check_tape(tapefd);
  238. X    smt_close(tapefd);
  239. X    rewind_named_device(tapename);
  240. X    if (!Quiet)
  241. X        printf("Tape in %s %s a labeled ExeTOC tape.\n", 
  242. X           tapename, hastoc ? "is" : "is not");
  243. X    exit(hastoc ? EXIT_OK : EXIT_NOTOC);
  244. X    
  245. X      case OP_FETCH:
  246. X    tapefd = smt_open(tapename, O_RDWR);
  247. X    if (!check_tape(tapefd))
  248. X    {   
  249. X        fprintf(stderr, "Tape in %s is not a labeled ExeTOC tape.\n", 
  250. X                    tapename);
  251. X        exit(EXIT_NOTOC);
  252. X    }
  253. X    toc_to_file(tapefd, tocfd);
  254. X    smt_close(tapefd);
  255. X    rewind_named_device(tapename);
  256. X    if (tocfd != fileno(stdout))
  257. X        close(tocfd);
  258. X    exit(EXIT_OK);
  259. X    
  260. X      case OP_STORE:
  261. X    tapefd = smt_open(tapename, O_RDWR);
  262. X    if (!check_tape(tapefd))
  263. X    {   
  264. X        fprintf(stderr, "Tape in %s is not a labeled ExeTOC tape.\n", 
  265. X                    tapename);
  266. X        exit(EXIT_NOTOC);
  267. X    }
  268. X    mark_tape(tapefd);
  269. X    toc_from_file(tapefd, tocfd);
  270. X    smt_close_without_eof(tapefd);
  271. X    rewind_named_device(tapename);
  272. X    if (tocfd != fileno(stdin))
  273. X        close(tocfd);
  274. X    exit(EXIT_OK);
  275. X    
  276. X      default:
  277. X    fprintf(stderr, "Unknown tape operation code (%d)\n", operation);
  278. X    exit(EXIT_USAGE);
  279. X    }
  280. X}
  281. X
  282. Xvoid    usage(progname)
  283. Xchar    *progname;
  284. X{   
  285. X    static char *summary = 
  286. X    "usage: %s [-t tape] [-g file] [-p file] [-i] [-v] [-q]\n";
  287. X    static char *syntax[] = {
  288. X    "",
  289. X    "\t-t specifies the tape device.  Default is $EXEBYTE, or /dev/rsmt0.",
  290. X    "\t-g gets the table of contents from the tape into the named file.",
  291. X    "\t-p puts the table of contants in the named file onto the tape.",
  292. X    "\t-i initializes a new tape so it can include a table of contents.",
  293. X    "\t-v verifies that a tape has previously been initialized.",
  294. X    "\t-q causes the program to work more quietly than usual.",
  295. X    "",
  296. X    "(Note: the tape is always rewound after any of these operations.)",
  297. X    NULL
  298. X    };
  299. X    char    *p;
  300. X    register int i;
  301. X    
  302. X    if ((p = rindex(progname, '/')) != NULL)
  303. X    progname = p+1;
  304. X
  305. X    fprintf(stderr, summary, progname);
  306. X    for (i = 0; syntax[i] != NULL; ++i)
  307. X    fprintf(stderr, "%s\n", syntax[i]);
  308. X}
  309. X
  310. X
  311. X     
  312. Xvoid    rewind_named_device(name)
  313. Xchar    *name;
  314. X{   
  315. X    int tapefd = smt_open(name, O_RDONLY);
  316. X    
  317. X    smt_rewind(tapefd);
  318. X    smt_close(tapefd);
  319. X}
  320. X
  321. X
  322. Xvoid    set_operation(op, opcode)
  323. Xint    *op;
  324. Xint    opcode;
  325. X{   
  326. X    if (*op != OP_NONE)
  327. X    {   
  328. X    fputs("Only one of -g, -p, -i, and -q may be supplied.\n", stderr);
  329. X    exit(EXIT_USAGE);
  330. X    }
  331. X    *op = opcode;
  332. X}
  333. X
  334. X
  335. Xint    check_open(name, mode, perm)
  336. Xchar    *name;
  337. Xint    mode;
  338. Xint    perm;
  339. X{   
  340. X    int    fd;
  341. X    
  342. X    if ((fd = open(name, mode, perm)) < 0)
  343. X    {   
  344. X    perror(name);
  345. X    exit(EXIT_IO);
  346. X    }
  347. X    return (fd);
  348. X}
  349. X
  350. X
  351. Xvoid    mark_tape(tapefd)
  352. Xint    tapefd;
  353. X{   
  354. X    bzero(Buffer, sizeof(Buffer));
  355. X    strcpy(Buffer, TOC_MARKER);
  356. X    smt_rewind(tapefd);
  357. X    if (smt_write(tapefd, Buffer, sizeof(Buffer)) < sizeof(Buffer))
  358. X    {   
  359. X    perror("tape label");
  360. X    exit(EXIT_IO);
  361. X    }
  362. X}
  363. X
  364. X
  365. Xvoid    initialize_tape(tapefd)
  366. Xint    tapefd;
  367. X{   
  368. X    int    nbufs = (TOC_SIZE / IOBUF_SIZE);
  369. X    
  370. X    mark_tape(tapefd);
  371. X    bzero(Buffer, sizeof(Buffer));
  372. X    while (--nbufs > 0)
  373. X    smt_write(tapefd, Buffer, sizeof(Buffer));
  374. X}
  375. X
  376. X
  377. Xint    check_tape(tapefd)
  378. Xint    tapefd;
  379. X{   
  380. X    smt_rewind(tapefd);
  381. X    return (smt_read(tapefd, Buffer, sizeof(Buffer)) == sizeof(Buffer) 
  382. X        &&
  383. X        streq(Buffer, TOC_MARKER));
  384. X}
  385. X
  386. X
  387. Xvoid    toc_to_file(tapefd, tocfd)
  388. Xint    tapefd;
  389. Xint    tocfd;
  390. X{   
  391. X    int           n;
  392. X    register int   i;
  393. X    register char *bp;
  394. X    
  395. X    bzero(Buffer, sizeof(Buffer));
  396. X    while ((n = smt_read(tapefd, Buffer, sizeof(Buffer))) > 0)
  397. X    {   
  398. X    if (n < sizeof(Buffer))
  399. X    {   
  400. X        perror("tape read");
  401. X        exit(EXIT_IO);
  402. X    }
  403. X    for (bp = Buffer, i = 0; i < sizeof(Buffer) && *bp != 0; bp++, i++)
  404. X        continue;
  405. X    if (write(tocfd, Buffer, i) != i)
  406. X    {   
  407. X        perror("file write");
  408. X        exit(EXIT_IO);
  409. X    }
  410. X    if (i < sizeof(Buffer))
  411. X        break;
  412. X    }
  413. X}
  414. X
  415. X
  416. Xvoid     toc_from_file(tapefd, tocfd)
  417. Xint    tapefd;
  418. Xint    tocfd;
  419. X{   
  420. X    struct stat s;
  421. X    int        n;
  422. X    
  423. X    if (tocfd != fileno(stdin))
  424. X    {   
  425. X    if (fstat(tocfd, &s) < 0)
  426. X    {   
  427. X        perror("fstat");
  428. X        exit(EXIT_IO);
  429. X    }
  430. X    if (s.st_size > TOC_USEABLE)
  431. X    {   
  432. X        fputs("Table of Contents file is too large.\n", stderr);
  433. X        exit(EXIT_TOOBIG);
  434. X    }
  435. X    }
  436. X    
  437. X    bzero(Buffer, sizeof(Buffer));
  438. X    while ((n = read(tocfd, Buffer, sizeof(Buffer))) > 0)
  439. X    {   
  440. X    if (n < sizeof(Buffer))
  441. X        bzero(Buffer + n, sizeof(Buffer) - n);
  442. X    if (smt_write(tapefd, Buffer, sizeof(Buffer)) < sizeof(Buffer))
  443. X    {   
  444. X        perror("tape write");
  445. X        exit(EXIT_IO);
  446. X    }
  447. X    }
  448. X    if (n < 0)
  449. X    {   
  450. X    perror("file read");
  451. X    exit(EXIT_IO);
  452. X    }
  453. X}
  454. END_OF_exetoc.c
  455. if test 8029 -ne `wc -c <exetoc.c`; then
  456.     echo shar: \"exetoc.c\" unpacked with wrong size!
  457. fi
  458. # end of overwriting check
  459. fi
  460. if test -f smtops.c -a "${1}" != "-c" ; then 
  461.   echo shar: Will not over-write existing file \"smtops.c\"
  462. else
  463. echo shar: Extracting \"smtops.c\" \(3587 characters\)
  464. sed "s/^X//" >smtops.c <<'END_OF_smtops.c'
  465. X#if !lint && !SABER
  466. Xstatic char RcsId[] = "$Header: smtops.c,v 1.2 89/10/27 16:14:58 mlandau Exp $";
  467. X#endif
  468. X
  469. X#include <stdio.h>
  470. X#include <fcntl.h>
  471. X#include <sys/types.h>
  472. X#include <sys/ioctl.h>
  473. X#include <sys/mtio.h>
  474. X
  475. X#if REMOTE
  476. X#include <rmt.h>
  477. X#endif
  478. X
  479. X#include "exitcodes.h"
  480. X#include "smtops.h"
  481. X
  482. X
  483. X/****************************************************************************
  484. X * BASIC MAGTAPE OPERATIONS FOR EXEBYTE DRIVES
  485. X ***************************************************************************/
  486. X
  487. X
  488. X/*
  489. X * smt_open():  Open a tape device.
  490. X * 
  491. X * Actually, it's just a wrapper around open, but data abstraction is 
  492. X * good, right?
  493. X */
  494. X
  495. Xint    smt_open(device, mode)
  496. Xchar    *device;
  497. Xint    mode;
  498. X{   
  499. X    int    fd;
  500. X    
  501. X    if ((fd = open(device, mode)) < 0)
  502. X    {   
  503. X    perror(device);
  504. X    exit(EXIT_IO);
  505. X    }
  506. X    return (fd);
  507. X}
  508. X
  509. X
  510. X/* 
  511. X * smt_close():  Close a tape device -- this is just a wrapper around close.
  512. X */
  513. Xvoid    smt_close(tapefd)
  514. Xint    tapefd;
  515. X{   
  516. X    if (close(tapefd) < 0)
  517. X    {   
  518. X    perror("tape close");
  519. X    exit(EXIT_IO);
  520. X    }
  521. X}
  522. X
  523. X
  524. X/* 
  525. X * smt_close_without_eof():  Rewind and close a tape device.
  526. X * 
  527. X *     This routine provides a rewind-and-close operation, which is
  528. X *     necessary to prevent the tape device driver from adding an EOF
  529. X *     mark to the tape if the last operation before closing the device
  530. X *     was a write.  Since we are continutally rewriting the same file,
  531. X *    we need to inform the driver that we don't want a new EOF mark
  532. X *     every time we do so.
  533. X */
  534. Xvoid    smt_close_without_eof(tapefd)
  535. Xint    tapefd;
  536. X{   
  537. X    smt_rewind(tapefd);
  538. X    smt_close(tapefd);
  539. X}
  540. X
  541. X
  542. X/* 
  543. X * smt_read():  Read from the tape drive
  544. X * smt_write(): Write to the tape drive
  545. X * 
  546. X * 
  547. X *     This are wrappers around read and write.  They're mostly here
  548. X *     so that we can use the rmt library if we want to.
  549. X */
  550. Xint    smt_read(tapefd, buffer, count)
  551. Xint    tapefd;
  552. Xchar    *buffer;
  553. Xint    count;
  554. X{   
  555. X    return (read(tapefd, buffer, count));
  556. X}
  557. X
  558. X
  559. Xint    smt_write(tapefd, buffer, count)
  560. Xint    tapefd;
  561. Xchar    *buffer;
  562. Xint    count;
  563. X{   
  564. X    return (write(tapefd, buffer, count));
  565. X}
  566. X
  567. X
  568. X/* 
  569. X * smt_status():  Return the status of the tape drive.
  570. X * 
  571. X * This code is cribbed from the mts command.  The smt_stat structure
  572. X * looks like this:
  573. X * 
  574. X *     struct smt_stat
  575. X *     {
  576. X *         char   smt_type[8];    -- cartridge type
  577. X *        u_long smt_remain;    -- KBytes left on tape
  578. X *        u_long smt_size;    -- Total size of tape (KBytes)
  579. X *         u_long smt_ecc;        -- ECC numbers
  580. X *         long   smt_wp:1;    -- write protected?
  581. X *         long   smt_bot:1;    -- at beginning of tape?
  582. X *    }
  583. X */
  584. X
  585. Xstruct smt_stat    *smt_status(tapefd)
  586. Xint         tapefd;
  587. X{   
  588. X    static struct smt_stat status;
  589. X    
  590. X    if (ioctl(tapefd, SMTIOGETSTAT, &status) < 0)
  591. X    {   
  592. X    perror("tape status");
  593. X    exit(EXIT_IO);
  594. X    }
  595. X    return (&status);
  596. X}
  597. X
  598. X
  599. X
  600. X/* 
  601. X * smt_rewind():  Rewind a tape and verify that it worked.
  602. X */
  603. X
  604. Xvoid    smt_rewind(tapefd)
  605. Xint    tapefd;
  606. X{   
  607. X    static struct mtop rewind_op = { MTREW, 1 };
  608. X    
  609. X    if (ioctl(tapefd, MTIOCTOP, &rewind_op) < 0)
  610. X    {   
  611. X    perror("tape rewind");
  612. X    exit(EXIT_IO);
  613. X    }
  614. X#if !REMOTE
  615. X    /* rmtlib.a does not like the custom ioctls used in the smt_status
  616. X       routine, so don't use it internally */
  617. X    if (!smt_status(tapefd)->smt_bot)
  618. X    {   
  619. X    fputs("Could not rewind tape for some unknown reason.");
  620. X    exit(EXIT_IO);
  621. X    }
  622. X#endif
  623. X}
  624. X
  625. X
  626. X/* 
  627. X * smt_eof():  Write an EOF mark on the tape.
  628. X * 
  629. X * We will probably never need this, but it doesn't hurt to include it.
  630. X */
  631. Xvoid    smt_eof(tapefd)
  632. Xint    tapefd;
  633. X{   
  634. X    static struct mtop eof_op = { MTWEOF, 1 };
  635. X    
  636. X    if (ioctl(tapefd, MTIOCTOP, &eof_op) < 0)
  637. X    {   
  638. X    perror("write eof");
  639. X    exit(EXIT_IO);
  640. X    }
  641. X}
  642. X
  643. X
  644. END_OF_smtops.c
  645. if test 3587 -ne `wc -c <smtops.c`; then
  646.     echo shar: \"smtops.c\" unpacked with wrong size!
  647. fi
  648. # end of overwriting check
  649. fi
  650. if test -f exitcodes.h -a "${1}" != "-c" ; then 
  651.   echo shar: Will not over-write existing file \"exitcodes.h\"
  652. else
  653. echo shar: Extracting \"exitcodes.h\" \(153 characters\)
  654. sed "s/^X//" >exitcodes.h <<'END_OF_exitcodes.h'
  655. X#ifndef EXITCODES_H
  656. X#define EXITCODES_H 1
  657. X
  658. X#define EXIT_OK        0
  659. X#define EXIT_USAGE    1
  660. X#define    EXIT_IO        2
  661. X#define EXIT_NOTOC    3
  662. X#define EXIT_TOOBIG    4
  663. X
  664. X#endif
  665. END_OF_exitcodes.h
  666. if test 153 -ne `wc -c <exitcodes.h`; then
  667.     echo shar: \"exitcodes.h\" unpacked with wrong size!
  668. fi
  669. # end of overwriting check
  670. fi
  671. if test -f smtio.h -a "${1}" != "-c" ; then 
  672.   echo shar: Will not over-write existing file \"smtio.h\"
  673. else
  674. echo shar: Extracting \"smtio.h\" \(445 characters\)
  675. sed "s/^X//" >smtio.h <<'END_OF_smtio.h'
  676. X#include <sys/ioctl.h>
  677. X
  678. X/* structures and defines for ioctls */
  679. Xstruct smt_stat {
  680. X    char    smt_type[8];    /* Cartridge type */
  681. X    unsigned long    smt_remain;        /* # of kilobytes remaining on tape */
  682. X    unsigned long    smt_size;        /* size (in kb) of tape */
  683. X    unsigned long    smt_ecc;        /* ECC count */
  684. X    long    smt_wp:1;        /* Write protected */
  685. X    long    smt_bot:1;        /* At beginning of tape */
  686. X};
  687. X
  688. X#define    SMTIOGETSTAT    _IOR(m,0,struct smt_stat)    /* get the drive status */
  689. END_OF_smtio.h
  690. if test 445 -ne `wc -c <smtio.h`; then
  691.     echo shar: \"smtio.h\" unpacked with wrong size!
  692. fi
  693. # end of overwriting check
  694. fi
  695. if test -f smtops.h -a "${1}" != "-c" ; then 
  696.   echo shar: Will not over-write existing file \"smtops.h\"
  697. else
  698. echo shar: Extracting \"smtops.h\" \(308 characters\)
  699. sed "s/^X//" >smtops.h <<'END_OF_smtops.h'
  700. X#ifndef    SMTOPS_H
  701. X#define    SMTOPS_H 1
  702. X
  703. X#include "smtio.h"
  704. Xextern    struct smt_stat    *smt_status();
  705. X
  706. Xextern    int            smt_open();
  707. Xextern    void            smt_close();
  708. Xextern  void         smt_close_without_eof();
  709. Xextern    void            smt_rewind();
  710. Xextern    void         smt_eof();
  711. Xextern    int         smt_read();
  712. Xextern    int         smt_write();
  713. X
  714. X#endif
  715. END_OF_smtops.h
  716. if test 308 -ne `wc -c <smtops.h`; then
  717.     echo shar: \"smtops.h\" unpacked with wrong size!
  718. fi
  719. # end of overwriting check
  720. fi
  721. if test -f exetoc.man -a "${1}" != "-c" ; then 
  722.   echo shar: Will not over-write existing file \"exetoc.man\"
  723. else
  724. echo shar: Extracting \"exetoc.man\" \(3224 characters\)
  725. sed "s/^X//" >exetoc.man <<'END_OF_exetoc.man'
  726. X.TH EXETOC 1L "27 Oct 1989"
  727. X.SH NAME
  728. Xexetoc \- Manage a table of contents on an Exebyte 2GB tape cartridge.
  729. X.SH SYNOPSIS
  730. X.B exetoc
  731. X.BI [-t tape ]
  732. X.BI [-g file ]
  733. X.BI [-p file ]
  734. X.B  [-i]
  735. X.B  [-v]
  736. X.B  [-q]
  737. X.SH DESCRIPTION
  738. X.B Exetoc is a program that allows you to write a table of contents
  739. Xfile onto the front of a 2GB helical scan tape, read it back later, 
  740. Xand update it without disturbing the other contents of the tape.  
  741. X.PP
  742. XIt does this by reserving a fixed amount of space at the start of 
  743. Xthe tape (about 10 megabytes in the current implementation) that can be 
  744. Xused to store information about the contents of the tape.  About 2 
  745. Xmegabytes of this space is available for keeping the table of
  746. Xcontents.  The rest acts as a buffer space between the end of the table 
  747. Xof contents and the first data file on the tape.
  748. X.SH OPTIONS
  749. X.B Exetoc understands the following options:
  750. X.TP
  751. X.BI -t tapedrive
  752. XSets the tape drive name to something other than the default, which
  753. Xis derived by looking for the environment variable EXETOC, or using
  754. X"/dev/rsmt0" if the environment variable is not set.  Exetoc is normally 
  755. Xlinked with the remote tape library, allowing you to use 
  756. Xnames of the form \fIhost:device\fP for direct access to remote tape 
  757. Xdrives.
  758. X.TP
  759. X.BI -g file
  760. XGets the table of contents from the tape and places a copy of
  761. Xit into the named file.  If \fIfile\fP is given as -, the table of 
  762. Xcontents is copied to standard output.
  763. X.TP
  764. X.BI -p file
  765. XPuts a table of contents onto the tape.  The contents of the table
  766. Xare taken from the named file, or from standard input if \fIfile\fP
  767. Xis given as -.  This flag may be used to create and rewrite tables
  768. Xof contents.
  769. X.TP
  770. X.B -i
  771. XInitializes a tape by creating a blank table of contents at the
  772. Xfront of the tape.  You must initialize a tape with the -i flag before
  773. Xyou can write a table of contents onto it for the first time.
  774. X.TP 
  775. X.B -v
  776. XVerifies that the tape in the tape drive has previously been initialized
  777. Xwith exetoc -i.
  778. X.TP
  779. X.B -q
  780. XCauses the program to work more quietly than it otherwise would.
  781. X.LP
  782. XAny other option causes exetoc to deliver a lengthy message explaining
  783. Xthe legal flags.
  784. X.SH "ENVIRIONMENT VARIABLES"
  785. X.TP
  786. XEXEBYTE
  787. XSpecifies the default tape drive to use.  Exetoc is normally linked
  788. Xwith the remote tape library, allowing you to use names of the form
  789. X\fIhost:device\fP for direct access to remote tape drives.
  790. X.SH "EXIT STATUS"
  791. XExetoc exits with one of the following well-defined status codes:
  792. X.TP
  793. X0
  794. Xindicates successful completion of an operation.
  795. X.TP
  796. X1
  797. Xindicates an error in usage (illegal command line flag, for instance).
  798. X.TP
  799. X2
  800. Xindicates an I/O error of some kind.  A diagnostic message is printed
  801. Xon standard error in this case, explaining what the error was.
  802. X.TP
  803. X3
  804. Xindicates that a read, write, or verify operation was attempted with a 
  805. Xtape that has never been initialized to hold a table of contents.
  806. X.TP
  807. X4
  808. Xindicates that the table of contents file you are trying to write onto
  809. Xthe tape is too large to fit.
  810. X.SH BUGS
  811. XThe tape is rewound after \fIany\fP exetoc operation, even if the no-rewind
  812. Xdevice was specified on the command line.
  813. X.SH "SEE ALSO"
  814. X.nf
  815. Xdd(1), bdd(1), mt(1)
  816. X.SH AUTHOR
  817. X.nf
  818. XMatt Landau, BBN Systems and Technologies Corp.  (mlandau@bbn.com)
  819. END_OF_exetoc.man
  820. if test 3224 -ne `wc -c <exetoc.man`; then
  821.     echo shar: \"exetoc.man\" unpacked with wrong size!
  822. fi
  823. # end of overwriting check
  824. fi
  825. echo shar: End of shell archive.
  826. exit 0
  827.  
  828. exit 0 # Just in case...
  829.